package com.qtjf.qtmoneyservice.widget;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.TextView;

import com.qtjf.qtmoneyservice.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/6 0006.
 */

public class RelateDialog extends Dialog {

    Context context;

    ScrollPickerView picker1;

    TextView okBt;
    TextView cancelBt;

    Handler handler;

   /* public SendMessageDialog(Context context){
        super(context);
        this.context = context;
    }*/

    public RelateDialog(Context context, int themeResId, Handler handler) {
        super(context, themeResId);
        this.context = context;
        this.handler = handler;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.dialog_relate_layout);

        picker1 = (ScrollPickerView) findViewById(R.id.picker_1);

        okBt = (TextView) findViewById(R.id.ok_bt);
        cancelBt = (TextView) findViewById(R.id.cancel_bt);

        List<String> lists = new ArrayList<String>();
        lists.add("父母");
        lists.add("配偶");
        lists.add("兄弟姐妹");

        picker1.setData(lists);
        picker1.setSelectedPosition(0);


        okBt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                String str=picker1.getSelectedItem();
                Message msg=Message.obtain();
                msg.arg1=9;
                msg.obj=str;
                handler.sendMessage(msg);

                RelateDialog.this.dismiss();
            }
        });

        cancelBt.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               /* Message msg=Message.obtain();
                msg.arg1=1;
                msg.obj="其他";
                handler.sendMessage(msg);*/

                RelateDialog.this.dismiss();
            }
        });
    }


    public void closeDialog() {
        this.dismiss();
    }

}
